/**
 * Created by shenc on 2015/12/8.
 */

$('.js-comment-btn').click(function(){
   var commentTr=$(this).closest('tr').next('.js-comment');
   if(commentTr.length==0) return false;

   commentTr.toggle();
});

//评价-评分
$('.show-score').each(function(){
   var that=$(this),
       scoreList=that.find('.bl-score'),
       scores=scoreList.find('span'),
       scoreTip=that.find('.score-tip'),
       scoreInput=that.find('.rating-input'),
       index=scoreInput.val()-1,
       txt=scoreTip.text();

   scoreList.on('mouseover click','span',function(e){
      var $this=$(this),
      curIndex=$this.index(),
      curTxt=$this.attr('title');
      for(var i=0;i<scores.length;i++){
         scores.eq(i).toggleClass('on', i<=curIndex);
      }
      scoreTip.text(curTxt);

      if(e.type=='click'){
         index=curIndex;
         txt=curTxt;
         scoreInput.val(index+1);
      }
   }).on('mouseout',function(){
      scores.eq(index).trigger('click');
   }).mouseout();


});

//评价-标签
$('.list-tags').on('click','.text',function(){
   $(this).closest('li').toggleClass('on');
});

//评价-表单验证
typeof $.validator == 'function' && $('.js-form').validate();



